package com.seckill.Controller;

import com.seckill.Common.BaseResponse;
import com.seckill.Model.DO.GoodsSeckill;
import com.seckill.Service.GoodsSecKillService;
import org.springframework.web.bind.annotation.*;

/**
 *商品秒杀任务管理
 * @author 不鄢
 */
@RestController
@RequestMapping("/api/a1/Snapped")
public class SnappedController {

    private GoodsSecKillService goodsSecKillService;

    /**
     * 创建商品秒杀任务
     * @param goodsSeckill
     * @return
     */
    @PostMapping("/create")
    public BaseResponse createSnapped(@RequestBody GoodsSeckill goodsSeckill ){
        return BaseResponse.success(goodsSecKillService.createSnapped(goodsSeckill));
    }

    @GetMapping("/list/{pageNp}/{pageSize}")
    public BaseResponse getSnappedList(@PathVariable("pageNo") Integer pageNo,
                                       @PathVariable("pageSize") Integer pageSize){
        return goodsSecKillService.getSnappedList(pageNo,pageSize);
    }

    @GetMapping("/{id}")
    public BaseResponse getSnappedById(@PathVariable("id") Long id){
        return goodsSecKillService.getSnappedById(id);
    }
}
